// component/video/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    key: {
      type: String,
      value: '',
    },
    src: {
      type: String,
      value: '',
    },
    isPlay: {
      type: Boolean,
      value: false,
      observer: function (n) {
        this.setData({ play: n });
        const { key } = this.properties;
        const videoContext = wx.createVideoContext('video' + key, this);
        n ? videoContext.play() : videoContext.pause();
      },
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    play: false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handePlay() {
      const { key } = this.properties;
      const { play } = this.data;
      const videoContext = wx.createVideoContext('video' + key, this);
      play ? videoContext.pause() : videoContext.play();
      this.setData({ play: !play });
    },
  },
});
